#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
typedef int SLDataType;
typedef struct SListNode
{
    struct SListNode* next;
    SLDataType Data;
}SLNode;
SLNode* BuyNode(SLDataType X)
{
    SLNode* newnode = (SLNode*)malloc(sizeof(SLNode));
    if (newnode == NULL)
    {
        printf("malloc is fail\n");
    }
    else
    {
        newnode->next = NULL;
        newnode->Data = X;
    }
    return newnode;
}
void SLNodePushBack(SLNode** pHead, SLDataType X)
{
    SLNode* newnode = BuyNode(X);
    if (*pHead == NULL)
    {
        *pHead = newnode;
    }
    else
    {
        SLNode* tail = *pHead;
        while (tail->next != NULL)
        {
            tail = tail->next;
        }
        tail->next = newnode;
    }
}
void SLNodeInsert(SLNode* pHead, SLDataType p)
{
    SLNode* prev = NULL;
    SLNode* cur = pHead;
    int j = 0;
    while (j < p)
    {
        j++;
        prev = cur;
        cur = cur->next;
    }
    SLNode* newnode = BuyNode(p);
    prev->next = newnode;
    newnode->next = cur;
}
void SLNodePrint(SLNode* pHead)
{
    SLNode* cur = pHead;
    while (cur != NULL)
    {
        printf("%d ", cur->Data);
        cur = cur->next;
    }
}
int main()
{
    SLNode* PList = NULL;
    int i, n, p = 0;
    int arr[100] = { 0 };
    scanf("%d %d", &n, &p);
    for (i = 0; i < n; i++)
    {
        scanf("%d ", &arr[i]);
        SLNodePushBack(&PList, arr[i]);
    }
    SLNodeInsert(PList, p);
    SLNodePrint(PList);
    free(PList);
    PList = NULL;
    return 0;
}